package com.freshcity.component.guide
{
	import com.freshcity.graphics.ArrowGuide;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	public class GuideArrow extends Sprite
	{
		private var _dir:int;
		private var _swfPlayer:MovieClip;
		
		public function GuideArrow()
		{
			this.mouseChildren = false;
			this.mouseEnabled = false;
		}
		
		public function updateDir(arg1:int):void
		{
			this.dispose();
			this._dir = arg1;
			this.onArrowLoaded();
		}
		
		private function onArrowLoaded():void
		{
			//this._swfPlayer.updateFrame(mortal.game.scene.modle.data.ActionType.Stand, 1, true);
			this._swfPlayer = new ArrowGuide();
			_swfPlayer.play();
			var loc1:*=0;
			var loc2:*=0;
			var loc3:*=this._dir;
			switch (loc3) 
			{
				case GuideArrowManager.Dir_L:
				{
					this._swfPlayer.rotation = 90;
					loc1 = this._swfPlayer.width / 2;
					break;
				}
				case GuideArrowManager.Dir_R:
				{
					this._swfPlayer.rotation = -90;
					loc1 = (-this._swfPlayer.width) / 2;
					break;
				}
				case GuideArrowManager.Dir_T:
				{
					this._swfPlayer.rotation = 180;
					loc2 = this._swfPlayer.height / 2;
					break;
				}
				case GuideArrowManager.Dir_B:
				{
					//this._swfPlayer.rotation = 90;
					loc2 = (-this._swfPlayer.height) / 2;
					break;
				}
			}
			this._swfPlayer.x = loc1;
			this._swfPlayer.y = loc2;
			addChild(this._swfPlayer);
		}
		
		public function dispose():void
		{
			if (this._swfPlayer) 
			{
				if (this._swfPlayer.parent == this) 
				{
					removeChild(this._swfPlayer);
				}
				//this._swfPlayer.dispose();
				this._swfPlayer.rotation = 0;
				this._swfPlayer.x = 0;
				this._swfPlayer.y = 0;
			}
		}
	}
}